<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>战役列表</title>
    <!--  抽取公共头部-->
    <div th:replace="admin/common :: head"></div>
</head>
<body>

<!--抽取公共导航栏-->
<div th:replace="admin/common :: menu(4)"></div>

<div class="m-padded-tb-hugex">
    <div class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a href="#" th:href="@{/admin/battle/append}" class="item">新增</a>
                <a href="#" class="teal active item">列表</a>
            </div>
        </div>
    </div>
</div>

<!--中间内容-->
<div class="m-padded-tb-big">
    <div class="ui container">
        <!--消息提示-->
        <div class="ui success message">
            <i class="close icon"></i>
            <div class="" th:text="|提示：${message}|" >提示：操作成功！</div>
        </div>
        <form th:action="@{/admin/battle}" method="post">
            <div class="ui secondary segment form" >
                <div class="inline fields">
                    <div class="field">
                        <input type="text" th:value="${condition.bname}" name="bname" placeholder="战役名称">
                    </div>
                    <div class="field">
                        <button type="submit" id="search-btn" class="ui mini teal basic button"><i class="search icon"></i>搜索</button>
                    </div>
                </div>
            </div>
        </form>
        <table class="ui compact teal table">
            <thead>
            <tr align="center">
                <th>ID</th>
                <th>战役名称</th>
                <th>图片地址</th>
                <th>添加时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr align="center" th:each="battle,statu:${pager.datas}">
                <td th:text="${statu.count}">1</td>
                <td th:text="${battle.bname}">ONESTAR</td>
                <td th:text="${battle.img}">https://onestar.newstar.net.cn/</td>
                <td th:text="${#dates.format(battle.createTime,'yyyy-MM-dd HH:mm')}">2020-01-02 09:45</td>
                <td>
                    <a href="#" th:href="@{/admin/battle/modify(battleId=${battle.battleId})}" class="ui mini teal basic button">编辑</a>
                    <a href="#" th:href="@{/admin/battle/delete/{battleId}(battleId=${battle.battleId})}" onclick="return confirm('确定要删除该战役吗？三思啊! 删了可就没了！')"
                       class="ui mini red basic button">删除</a>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <th colspan="6">
                    <div class="ui inverted divided stackable grid">
                        <div class="three wide column" align="center">
                            <a th:if="${pager.has_pre}" th:href="@{/admin/battle}" class="item">首页</a>&nbsp;&nbsp;&nbsp;
                            <a th:if="${pager.has_pre}" th:href="@{/admin/battle(page=${pager.page}-1)}" class="item">上一页</a>
                        </div>

                        <div class="ten wide column" align="center">
                            <p>第 <span th:text="${pager.page}"></span> 页，共 <span th:text="${pager.pages}"></span> 页，有 <span th:text="${pager.size}"></span> 篇文章</p>
                        </div>

                        <div class="three wide column" align="center">
                            <a th:if="${pager.has_next}" th:href="@{/admin/battle(page=${pager.page}+1)}" class="item">下一页</a>&nbsp;&nbsp;&nbsp;
                            <a th:if="${pager.has_next}" th:href="@{/admin/battle(page=${pager.last})}" class="item">末页</a>
                        </div>
                    </div>
                    <div align="center">
                        <a href="#" th:href="@{/admin/battle/append}">
                            <button type="button" class="ui teal button m-mobile-wide m-margin-top"><i
                                    class="pencil icon"></i>新增
                            </button>
                        </a>
                    </div>
                </th>
            </tr>
            </tfoot>
        </table>
    </div>
</div>

<br>
<br>
<!--抽取公共底部栏-->
<div th:replace="admin/common :: #footer"></div>

<!--抽取公共js-->
<div th:replace="admin/common :: #js"></div>
<script>
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });

    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    //消息提示关闭初始化
    $('.message .close')
        .on('click', function () {
            $(this)
                .closest('.message')
                .transition('fade');
        });
</script>
</body>
</html>